/**
 *查询日报表与搜索框的模糊查询，有模糊查询，传日期名称字段
 */

var Grid = BUI.Grid,
    Store = BUI.Data.Store,
    columns = [
        {
            title: '序号', dataIndex: 'flowDailyReportId',elCls: 'center',width:'8%', renderer: function (value,obj,index) {
                return index+1;
            }
        },
        {title: '设备名称', dataIndex: 'name',elCls: 'center',width:'16%'},
        {title: '流量（m3/h）', dataIndex: 'curFlow',elCls: 'center',width:'12%', renderer: function (value) {
                return value== null ? "____ " : (value.toFixed(2)+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }},
        {title: '流速（m/s）', dataIndex: 'curSpeed', elCls: 'center',width:'12%',renderer: function (value) {
                return value== null ? "____" : (value.toFixed(2)+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }},
        {title: '正向总量（m3）', dataIndex: 'curTotalPositive',elCls: 'center',width:'12%', renderer: function (value) {
                return value==""||value==null? "____ " : (parseInt(value)+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }},
        {title: '设备信息', dataIndex: 'curAlarm',elCls: 'center',width:'12%', renderer: function (value) {
                return value==""||value==null? "____ " : value
            }},
        {title: '通讯状态',dataIndex :'sts',elCls: 'center',width:'12%', renderer: function (value) {
                return value==0?"<span style='color:#d9534f'>异常</span>":"<span>正常</span>";
            }
        },
        {title: '更新时间', dataIndex: 'updateTime',elCls: 'center',width:'16%', renderer: function (value) {
                return value==null?"____":new Date(value).Format("yyyy-MM-dd hh:mm:ss");
            }
        }

    ];
//分页查询
var store = new Store({
        url: ' /rest/web/device/selectDevicePage',
        autoLoad: true, //自动加载数据
        params: { //配置初始请求的参数
            length: '15',
            start: '0'
        },
        pageSize: 15,	// 配置分页数目
        root: 'data.list',
        totalProperty: 'data.totalCount'
    }),
    grid = new Grid.Grid({
        render: '#grid',
        columns: columns,
        loadMask: true, //加载数据时显示屏蔽层
        store: store,
        plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格
        // 底部工具栏
        bbar: {
            pagingBar: true
        }
    });

grid.render();

